package com.hdu.seckilldemo.controller;
import com.hdu.seckilldemo.pojo.User;
import com.hdu.seckilldemo.rabbitmq.MQSender;
import com.hdu.seckilldemo.vo.RespBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lwy
 * @since 2023-02-07
 */

@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private MQSender mqSender;
    @RequestMapping("/info")
    @ResponseBody
    public RespBean info(User user){
        return RespBean.success(user);
    }


/*    //测试mq发送
    @RequestMapping("/mq")
    @ResponseBody
    public void send(){
        mqSender.send("hello wold");
    }
    // fanout模式测试 将消息发送到 exchange绑定的所有队列上
    @RequestMapping("/mq/fanout")
    @ResponseBody
    public void send01(){
        mqSender.send("Hello");
    }
    // direct模式测试
    @RequestMapping("/mq/direct")
    @ResponseBody
    public void send02(){
        mqSender.send_red("Hello red");
        mqSender.send_green("hello green");
    }

    *//**
     *  topic模式测试
     *  ROUTINGKEY03 = "#.queue.#";
     *  ROUTINGKEY04 = "*.queue.*";
     *  那么KEY04会收到两条消息
     *//*
    @RequestMapping("/mq/topic")
    @ResponseBody
    public void send03(){
        mqSender.send_topic01("hello topic(key1.queue.key2)","key1.queue.key2");
        mqSender.send_topic01("hello topic(key3.key1.queue.key2.key4)","key3.key1.queue.key2.key4");
    }

    */
    /**
     * header模式测试
     */
/*    @RequestMapping("/mq/header01")
    @ResponseBody
    public void send04(){
        mqSender.send_header01("hello header01");
    }
    @RequestMapping("/mq/header02")
    @ResponseBody
    public void send05(){
        mqSender.send_header02("hello header02");
    }*/


}
